/**
 * Created by Administrator on 2017/5/25.
 */
"use strict";
//引入模块
const mongoose = require('mongoose');
const db = require('./db');

// Schema 结构
var AuthorSchema = new mongoose.Schema({
    cid      :{type:Number,index: true},//cid
    bAuth     :{type:String},//作者
    grade     :{type:Number,default:1},//等级
    imgurl    :{type : String,default:"/up/images/head/head.png"},//头像路径
    desc  :{type : String,default:'暂无简介'}//简介
});

AuthorSchema.statics.findFn = function(obj,obj1, callback) {
    return this.model('Author').find(obj, callback).sort(obj1);
};
AuthorSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Author').findOne(obj).sort(obj1).exec(callback);
};
AuthorSchema.statics.findLimitSkip = function(obj,num1,num2,obj1,callback) {
    return this.model('Author').find(obj).limit(num1).skip(num2).sort(obj1).exec(callback);
};
AuthorSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Author').findOne(obj).sort(obj1).exec(callback);
};
AuthorSchema.statics.updateFn = function(obj,obj1,callback) {
    return this.model('Author').update(obj,obj1).exec(callback);
};
AuthorSchema.statics.removeFn = function(obj,callback) {
    return this.model('Author').remove(obj,callback);
};
AuthorSchema.statics.findConut = function(obj,callback) {
    return this.model('Author').find(obj).count().exec(callback);
};

var AuthorModel = db.model('Author', AuthorSchema);

module.exports=AuthorModel;